package com.webchat.ugc.service.mall.im.convert;


import com.webchat.common.enums.mall.im.MallImMessageTypeEnum;
import com.webchat.domain.vo.dto.mall.im.UgcServerMessageDTO;
import org.springframework.util.Assert;

public abstract class MessageConverter<T> {


    /**
     * 消息内容转文本
     *
     * @return
     */
    protected abstract String convertText(UgcServerMessageDTO<T> msg);


    protected String convertTextMessage(UgcServerMessageDTO<T> msg) {
        Assert.notNull(msg, "msg is null");
        Assert.isTrue(MallImMessageTypeEnum.isSupport(msg.getMessageType()), "msg type is not support");
        return convertText(msg);
    }
}
